package com.aspose.cells;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;

public class WorkbookDesigner {
   private Workbook a;
   private HashMap b;
   private Object c;
   private com.aspose.cells.b.a.g.a.ze d = new com.aspose.cells.b.a.g.a.ze("\\((.+)\\)", 66);
   private com.aspose.cells.b.a.g.a.ze e = new com.aspose.cells.b.a.g.a.ze("^\\((.+)\\)$", 66);
   private boolean f;
   private boolean g = false;
   private zbnm h = null;
   private ArrayList i;
   private static final com.aspose.cells.b.c.a.za j = new com.aspose.cells.b.c.a.za(new String[]{"label", "labelposition", "rangeborder", "copystyle", "horizontal", "noadd", "numeric", "shift", "group", "picture", "html", "bean", "normal", "repeat", "merge"});

   public Workbook getWorkbook() {
      return this.a;
   }

   public void setWorkbook(Workbook value) {
      this.a = value;
   }

   public WorkbookDesigner() {
      this.a = new Workbook();
      this.b = new HashMap();
   }

   public WorkbookDesigner(Workbook workbook) {
      this.a = workbook;
      this.b = new HashMap();
   }

   public void clearDataSource() {
      this.c = null;
      this.b.clear();
   }

   public void setDataSource(String variable, Object data) {
      if (variable != null && !"".equals(variable)) {
         Object[] var4;
         int var5;
         if (data instanceof int[]) {
            int[] var3 = (int[])((int[])data);
            var4 = new Object[var3.length];

            for(var5 = 0; var5 < var3.length; ++var5) {
               var4[var5] = com.aspose.cells.b.a.za.a((Object)var3, var5);
            }

            this.a((String)variable, (ICellsDataTable)(new zhv(variable, var4)));
         } else if (data instanceof double[]) {
            double[] var6 = (double[])((double[])data);
            var4 = new Object[var6.length];

            for(var5 = 0; var5 < var6.length; ++var5) {
               var4[var5] = com.aspose.cells.b.a.za.a((Object)var6, var5);
            }

            this.a((String)variable, (ICellsDataTable)(new zhv(variable, var4)));
         } else if (data instanceof String[]) {
            this.a((String)variable, (ICellsDataTable)(new zhv(variable, (Object[])((Object[])data))));
         } else if (data instanceof Collection) {
            Collection var7 = (Collection)data;
            this.a(variable, zbni.a(var7));
         } else {
            this.a((String)variable, (ICellsDataTable)(new zhv(variable, new Object[]{data})));
         }
      }

   }

   public void setDataSource(String variable, Object[] dataArray) {
      if (variable != null && !"".equals(variable)) {
         this.a((String)variable, (ICellsDataTable)(new zhv(variable, dataArray)));
      }

   }

   private void a(zbnm var1) throws Exception {
      Worksheet var2 = var1.a();
      this.b(var2.getCells(), var1);
      int var3 = -1;
      boolean var4 = false;
      ArrayList var5 = new ArrayList();

      for(int var6 = 0; var6 < var1.getCount(); ++var6) {
         zbnh var7 = var1.a(var6);
         if (var7.f) {
            if (var3 == -1) {
               var3 = var7.b;
            } else if (var3 != var7.b) {
               if (var5.size() != 0) {
                  this.a(var2.getCells(), var3, var5, var4);
               }

               var3 = var7.b;
               var5.clear();
               var4 = false;
            }

            if (var7.r) {
               var4 = true;
            }

            com.aspose.cells.b.a.a.ze.a(var5, (Object)var7);
         }
      }

      if (var5.size() != 0) {
         this.a(var2.getCells(), var3, var5, var4);
      }

   }

   private void a(Cells var1, int var2, ArrayList var3) {
      CellArea var4 = new CellArea();
      var4.StartRow = var2;
      DataSorter var5 = new DataSorter(this.getWorkbook());
      boolean var6 = false;

      for(int var7 = 0; var7 < var3.size(); ++var7) {
         zbnh var8 = (zbnh)var3.get(var7);
         if (var7 == 0) {
            var4.StartColumn = var8.c;
            var4.EndRow = var8.c() + var2;
         }

         var4.EndColumn = var8.c;
         if (var8.f && var8.F != -1) {
            if (var8.a == 1 || var8.a == 2) {
               var6 = true;
            }

            zql var9 = new zql(var5);
            int var10 = var8.F - 1;
            var9.b(var8.c);
            var9.a(var8.G ? 0 : 1);
            if (var10 >= var5.a().size()) {
               com.aspose.cells.b.a.a.ze.a(var5.a(), (Object)var9);
            } else {
               var5.a().add(var10, var9);
            }
         }
      }

      if (var6) {
         this.a.calculateFormula();
      }

      var5.sort(var1, var4);
   }

   private void a(Cells var1, int var2, ArrayList var3, boolean var4) throws Exception {
      zbnh var5 = null;
      ArrayList var6 = new ArrayList();
      com.aspose.cells.b.a.a.ze.a(var6, (Collection)var3);

      for(int var7 = 0; var7 < var3.size(); ++var7) {
         var5 = (zbnh)var3.get(var7);
         var5.a();
         if (var5.a == 1) {
            String var8 = zbni.a(var5.m, var5.b, var5.c);
            var1.a(var5.b, var5.c, false).setFormula(var8);
            var3.remove(var7--);
         }
      }

      Object var14 = null;

      int var15;
      while(var3.size() > 0) {
         var5 = null;

         for(var15 = 0; var15 < var3.size(); ++var15) {
            var5 = (zbnh)var3.get(var15);
            if (var5.a == 0) {
               break;
            }

            var5 = null;
         }

         if (var5 == null) {
            break;
         }

         switch(var5.a) {
         case 0:
            boolean var16 = false;
            boolean[] var9 = new boolean[]{var16};
            ArrayList var10 = this.a(var3, var5.m, true, var9, true);
            var16 = var9[0];
            ICellsDataTable var11 = this.b(var5.m);
            int var12;
            if (var11.getCount() == 0) {
               var12 = 0;

               while(var12 < var10.size()) {
                  var5 = (zbnh)var10.get(var12);
                  switch(var5.a) {
                  case 2:
                     this.a(var5, var1, var5.d, var5.e);
                  default:
                     ++var12;
                  }
               }
            } else if (!var16) {
               var12 = 0;
               int var13 = 0;

               for(; var13 < var10.size(); ++var13) {
                  var5 = (zbnh)var10.get(var13);
                  if (var5.a == 0 && var5.l > var12) {
                     var12 = var5.l;
                  }
               }

               for(var13 = 0; var13 < var10.size(); ++var13) {
                  var5 = (zbnh)var10.get(var13);
                  if (var5.a == 2 && var5.l == 0) {
                     var5.l = var12;
                  }
               }

               var11.beforeFirst();

               while(var11.next()) {
                  for(var13 = 0; var13 < var10.size(); ++var13) {
                     var5 = (zbnh)var10.get(var13);
                     switch(var5.a) {
                     case 0:
                        var14 = var11.get(var5.o);
                        this.a(var5, var1, var5.d, var5.e, var14);
                        var5.d += var5.l + 1;
                        break;
                     case 2:
                        this.a(var5, var1, var5.d, var5.e);
                        var5.d += 1 + var5.l;
                     }
                  }
               }
            } else {
               this.a(var1, var10, var11);
            }
         }
      }

      if (var3.size() != 0) {
         for(var15 = 0; var15 < var3.size(); ++var15) {
            var5 = (zbnh)var3.get(var15);
            if (var5.a == 2) {
               this.a(var5, var1, var5.d, var5.e);
            }
         }
      }

      this.a(var1, var2, var6);
   }

   private void a(Cells var1, ArrayList var2, ICellsDataTable var3) {
      boolean var4 = false;
      zbnh var5 = (zbnh)var2.get(0);
      int var6 = 0;
      ArrayList var7 = new ArrayList();
      int var8 = var5.b;
      HashMap var9 = new HashMap();
      int var10 = 0;

      int var12;
      ArrayList var13;
      for(int var11 = 0; var11 < var2.size(); ++var11) {
         var5 = (zbnh)var2.get(var11);
         if (var5.r) {
            var5.t = -1;
            if (var5.s == -1) {
               var5.s = var10;
            }

            ++var10;
         } else if (var5.y != null) {
            for(var12 = 0; var12 < var5.y.length; ++var12) {
               if (!var9.containsKey(var5.y[var12])) {
                  var13 = new ArrayList();
                  com.aspose.cells.b.a.a.ze.a(var13, (Object)var5);
                  var9.put(var5.y[var12], var13);
               } else {
                  var13 = (ArrayList)var9.get(var5.y[var12]);
                  com.aspose.cells.b.a.a.ze.a(var13, (Object)var5);
               }
            }
         }
      }

      zbnh[] var19 = new zbnh[var10];

      for(var12 = 0; var12 < var2.size(); ++var12) {
         var5 = (zbnh)var2.get(var12);
         if (var5.r) {
            var19[var5.s] = var5;
         }
      }

      HashMap var20 = null;
      var3.beforeFirst();

      int var21;
      while(var3.next()) {
         if (var20 == null) {
            var20 = this.a(var20, var3, var2, var8);
         } else {
            var13 = new ArrayList();
            int var14 = 0;

            while(true) {
               if (var14 >= var19.length) {
                  if (var7.size() == 0) {
                     break;
                  }

                  int[] var22 = new int[]{var8};
                  this.a(var1, var22, var7, var9, var4, var2, var20);
                  var8 = var22[0];

                  int var24;
                  for(var24 = 0; var24 < var7.size(); ++var24) {
                     var5 = (zbnh)var7.get(var24);
                     var5.t = -1;
                  }

                  for(var24 = 0; var24 < var13.size(); ++var24) {
                     var5 = (zbnh)var13.get(var24);
                     var5.t = var8;
                  }

                  var20 = this.a(var20, var3, var2, var8);
                  var6 = 0;
                  var7.clear();
                  var4 = false;
                  break;
               }

               label140: {
                  var13.clear();
                  var5 = var19[var14];
                  Object var15 = var20.get(var5.o);
                  Object var16 = var3.get(var5.o);
                  boolean var17 = zbni.a(var15);
                  boolean var18 = zbni.a(var16);
                  if (var17) {
                     if (var18) {
                        break label140;
                     }

                     if (var5.t == -1) {
                        var5.t = var8;
                        var20.put(var5.o, var16);
                        com.aspose.cells.b.a.a.ze.a(var13, (Object)var5);
                        break label140;
                     }
                  } else if (!var18 && var15.equals(var16)) {
                     break label140;
                  }

                  for(; var14 < var19.length; ++var14) {
                     var5 = var19[var14];
                     if (var5.t != -1) {
                        if (var6 < var5.l) {
                           var6 = var5.l;
                        }

                        com.aspose.cells.b.a.a.ze.a(var7, (Object)var5);
                        if (var9.containsKey(var5.n)) {
                           var4 = true;
                        }
                     }
                  }
               }

               ++var14;
            }
         }

         for(var21 = 0; var21 < var2.size(); ++var21) {
            var5 = (zbnh)var2.get(var21);
            if (var5.a == 2) {
               var1.a(var8, var5.c, false).setFormula(zbni.a(var5.m, var8, var5.c));
            } else {
               Object var25 = var3.get(var5.o);
               if (var5.r && var5.b == var8 && zbni.a(var25)) {
                  var1.a(var8, var5.c, false).e();
               } else if (var5.r && var5.t != var8) {
                  switch(var5.v) {
                  case 1:
                     if (var25 != null && zamo.a(var25.getClass()) == 18) {
                        var1.a(var8, var5.c, false).putValue((String)var25, var5.q);
                     } else {
                        var1.a(var8, var5.c, false).putValue(var25);
                     }
                  }
               } else if (var5.a == 0) {
                  if (var25 != null && zamo.a(var25.getClass()) == 18) {
                     var1.a(var8, var5.c, false).putValue((String)var25, var5.q);
                  } else {
                     var1.a(var8, var5.c, false).putValue(var25);
                  }
               }
            }
         }

         ++var8;
      }

      for(var21 = 0; var21 < var2.size(); ++var21) {
         var5 = (zbnh)var2.get(var21);
         if (var5.r && var5.t != -1) {
            com.aspose.cells.b.a.a.ze.a(var7, (Object)var5);
         }

         if (var5.a != 2 && var9.containsKey(var5.n)) {
            var4 = true;
         }
      }

      int[] var23 = new int[]{var8};
      this.a(var1, var23, var7, var9, var4, var2, var20);
      var8 = var23[0];
   }

   private void a(Cells var1, int[] var2, ArrayList var3, HashMap var4, boolean var5, ArrayList var6, HashMap var7) {
      zbnh var8 = null;
      int var9 = var2[0];
      Row var10 = null;
      boolean var11 = false;

      int var12;
      for(var12 = var6.size() - 1; var12 >= 0; --var12) {
         var8 = (zbnh)var6.get(var12);
         if (var8.C != null) {
            var10 = var8.C;
         }

         if (var8.g) {
            var11 = var8.g;
         }
      }

      int var13;
      if (var5 && var11 && var10 != null && var2[0] != var10.getIndex()) {
         Row var24 = var1.getRows().a(var2[0], false, true, false);
         var24.a(var10);

         for(var13 = 0; var13 < var10.a(); ++var13) {
            Cell var14 = var10.getCellByIndex(var13);
            var24.c(var14.getColumn()).b(var14.s());
         }
      }

      var12 = 0;
      var13 = var3.size() - 1;

      while(var13 >= 0) {
         var8 = (zbnh)var3.get(var13);
         int var25 = 0;
         int var15 = 16383;
         int var16 = -1;
         int var17 = var8.t;
         byte var18 = 0;
         if (var5) {
            if (var4.containsKey(var8.n)) {
               ArrayList var19 = (ArrayList)var4.get(var8.n);

               for(int var20 = 0; var20 < var19.size(); ++var20) {
                  zbnh var21 = (zbnh)var19.get(var20);
                  Cell var22 = var1.a(var2[0], var21.c, false);
                  if (var21.x != null) {
                     var22.setFormula(zbni.a(var21.x, true, var17, var21.c, var2[0] - 1, var21.c));
                  } else {
                     String var23 = CellsHelper.cellIndexToName(var17, var21.c) + ":" + CellsHelper.cellIndexToName(var2[0] - 1, var21.c);
                     var22.setFormula("=SUBTOTAL(" + var21.w + "," + var23 + ")");
                  }

                  if (var21.B != -1) {
                     var22.b(var21.B);
                  }

                  if (var21.z != null && var21.z.get(var8.n) != null) {
                     zbnj var31 = (zbnj)((zbnj)var21.z.get(var8.n));
                     var22 = var1.a(var2[0], var21.c + var31.b, false);
                     var22.putValue(com.aspose.cells.b.a.zv.a(var31.a, var7.get(var8.o)));
                     if (var8.v == 2 && var21.c + var31.b == var8.e) {
                        var18 = 1;
                     }

                     if (var31.c && var31.b < 0) {
                        if (var22.getColumn() < var15) {
                           var15 = var22.getColumn();
                        }

                        if (var21.c > var16) {
                           var16 = var21.c;
                        }
                     }
                  }
               }

               ++var25;
            }

            int var26;
            for(var26 = 0; var26 < var6.size(); ++var26) {
               zbnh var27 = (zbnh)var6.get(var26);
               Cell var29;
               if (var27.D != null) {
                  var29 = var1.a(var2[0], var27.c, false);
                  var29.b(var27.B);
                  if (var27.E) {
                     var29.setFormula(zbni.a(var27.D, var29.getRow(), var29.getColumn()));
                  } else {
                     var29.putValue(var27.D);
                  }
               } else if (var27.B != -1 && var4.containsKey(var8.n)) {
                  var29 = var1.a(var2[0], var27.c, false);
                  var29.b(var27.B);
               }
            }

            if (var16 > 0) {
               for(var26 = var15; var26 < var16; ++var26) {
                  Cell var28 = var1.a(var2[0], var26, false);
                  Style var30 = var28.getStyle(false);
                  if (var30.getBorders().getByBorderType(2).getLineStyle() != 0) {
                     var30.getBorders().getByBorderType(2).setLineStyle(0);
                     var28.setStyle(var30);
                  }
               }
            }
         }

         switch(var8.v) {
         case 2:
            var1.merge(var17, var8.c, var2[0] - var17 + var25 - var18, 1);
         case 0:
         default:
            if (var8.l > 0) {
               if (var25 != 0) {
                  var25 += var8.l;
               } else if (var8.l > var12) {
                  var12 = var8.l;
               }
            }

            var2[0] += var25;
            --var13;
         }
      }

      var2[0] += var12;
   }

   private void a(Cells var1, zbnh var2, int var3, int var4, byte[] var5) throws Exception {
      com.aspose.cells.b.a.d.zh var6 = new com.aspose.cells.b.a.d.zh((byte[])var5);
      if (var2.K) {
         com.aspose.cells.b.a.b.zj var7 = com.aspose.cells.b.a.b.zj.a((com.aspose.cells.b.a.d.zm)var6);
         int var8 = var1.getColumnWidthPixel(var4);
         int var9 = var1.getRowHeightPixel(var3);
         int var10 = (int)((double)((float)var9 * 100.0F / (float)var7.h()) + 0.5D);
         int var11 = (int)((double)((float)var8 * 100.0F / (float)var7.i()) + 0.5D);
         var1.h().getPictures().a(var3, var4, var6, var11, var10);
      } else if (var2.L) {
         var1.h().getPictures().a(var3, var4, var6, var2.V, var2.U);
      } else {
         int var12 = var1.h().getPictures().a(var3, var4, var6);
         Picture var14 = var1.h().getPictures().get(var12);
         if (var2.M) {
            var14.setLeft(var2.N);
         }

         if (var2.O) {
            var14.setTop(var2.P);
         }

         if (var2.Q) {
            var14.setWidth(var2.R);
         }

         if (var2.S) {
            var14.setHeight(var2.T);
         }
      }

      Cell var13 = var1.checkCell(var3, var4);
      if (var13 != null) {
         var13.putValue((String)null);
      }

   }

   private void a(String var1, zbnh var2) {
      try {
         String var3 = var1.substring("subtotal".length());
         int var4 = var3.indexOf(58);
         if (var4 == -1) {
            var2.w = com.aspose.cells.b.a.zo.a(var3.substring(0));
         } else {
            var2.w = com.aspose.cells.b.a.zo.a(var3.substring(0, 1));
            String[] var5 = com.aspose.cells.b.a.zv.d(var3.substring(var4 + 1), '&');
            if (var5[var5.length - 1] != null && var5[var5.length - 1].startsWith("formula")) {
               String var6 = var5[var5.length - 1];

               for(int var7 = "formula".length(); var7 < var6.length(); ++var7) {
                  if (var6.charAt(var7) == '=') {
                     var2.x = var6.substring(var7);
                     break;
                  }
               }

               if (var2.x != null) {
                  String[] var17 = new String[var5.length - 1];
                  System.arraycopy(var5, 0, var17, 0, var17.length);
                  var5 = var17;
               }
            }

            var2.y = new String[var5.length];

            for(int var16 = 0; var16 < var5.length; ++var16) {
               String var18 = var5[var16];
               String[] var8 = zbni.a(var18);
               String[] var9 = com.aspose.cells.b.a.zv.d(var8[0], '.');
               var9[1] = zbni.b(var9[1]);
               var2.y[var16] = var9[1];
               if (var8.length > 1) {
                  if (var2.z == null) {
                     var2.z = new HashMap();
                  }

                  zbnj var10 = new zbnj();
                  var2.z.put(var2.y[var16], var10);

                  for(int var11 = 1; var11 < var8.length; ++var11) {
                     var4 = var8[var11].indexOf(58);
                     String var12 = var8[var11];
                     String var13 = "";
                     if (var4 != -1) {
                        var12 = var8[var11].substring(0, 0 + var4);
                        var13 = var8[var11].substring(var4 + 1);
                     }

                     switch(j.a(var12.toLowerCase())) {
                     case 0:
                        String var14 = var13;
                        if (var13.charAt(0) == '"') {
                           var14 = var13.substring(1, 1 + (var13.length() - 2));
                        }

                        var10.a = var14;
                        break;
                     case 1:
                        var10.b = com.aspose.cells.b.a.zo.a(var13.trim());
                        break;
                     case 2:
                        var10.c = true;
                     }
                  }
               }
            }
         }
      } catch (Exception var15) {
         ;
      }

   }

   void a(Cell var1, zbnh var2, ArrayList var3, boolean var4) {
      String var5 = var1.j().substring(2);
      String var7 = null;
      int var8;
      com.aspose.cells.b.a.g.a.zc var9;
      if (var5.charAt(0) != '=' && var5.charAt(0) != '&') {
         if (var5.charAt(0) == '[') {
            var8 = var5.indexOf("].[");
            if (var8 != -1) {
               var8 = var5.indexOf(93, var8 + 2) + 1;
               if (var8 >= var5.length()) {
                  var7 = "";
               } else {
                  var7 = var5.substring(var8);
                  if (var7 != null && !"".equals(var7) && var7.charAt(0) == '(' && var7.charAt(var7.length() - 1) == ')') {
                     var7 = var7.substring(1, 1 + (var7.length() - 2));
                  }
               }

               var5 = var5.substring(0, 0 + var8);
            } else {
               var9 = this.d.a(var5);
               if (var9.c()) {
                  var7 = var9.b().a(1).b();
                  var5 = var5.substring(0, 0 + var5.indexOf("("));
               }
            }
         } else {
            com.aspose.cells.b.a.g.a.zc var18 = this.d.a(var5);
            if (var18.c()) {
               var7 = var18.b().a(1).b();
               var5 = var5.substring(0, 0 + var5.indexOf("("));
            }
         }
      } else {
         var8 = var5.lastIndexOf(126);
         if (var8 != -1) {
            var7 = var5.substring(var8 + 1);
            var9 = this.e.a(var7);
            if (var9.c()) {
               var5 = var5.substring(0, 0 + var8);
               var7 = var9.b().a(1).b();
            } else {
               var7 = null;
            }
         }
      }

      String[] var6;
      if (var7 != null) {
         var6 = com.aspose.cells.b.a.zv.d(var7, ',');
         if (var6.length > 0) {
            String[] var19 = var6;
            int var20 = var6.length;

            for(int var10 = 0; var10 < var20; ++var10) {
               String var11 = var19[var10];
               String var12 = var11.trim().toLowerCase();
               switch(j.a(var12)) {
               case 3:
                  var2.h = true;
                  var2.i = var1.s();
                  break;
               case 4:
                  var2.f = false;
                  break;
               case 5:
                  var2.g = false;
                  break;
               case 6:
                  var2.q = true;
                  break;
               case 7:
                  var2.g = false;
                  var2.j = true;
                  break;
               case 8:
                  var2.r = true;
                  break;
               case 9:
                  var2.J = true;
                  var2.L = true;
                  break;
               case 10:
                  var2.I = true;
                  break;
               case 11:
                  var2.H = true;
                  break;
               default:
                  if (var12.indexOf("skip:") != -1) {
                     try {
                        var2.l = com.aspose.cells.b.a.zo.a(var12.substring(5));
                     } catch (Exception var17) {
                        ;
                     }
                  } else if (var12.indexOf("shift:") != -1) {
                     try {
                        var2.g = false;
                        var2.j = true;
                        var2.k = com.aspose.cells.b.a.zo.a(var12.substring(5));
                     } catch (Exception var16) {
                        ;
                     }
                  } else if (var12.indexOf("subtotal") != -1) {
                     this.a(var11, var2);
                  } else if (var12.indexOf("group:") != -1) {
                     var2.r = true;
                     var12 = var12.substring("group:".length());
                     switch(j.a(var12)) {
                     case 12:
                        var2.v = 0;
                        break;
                     case 13:
                        var2.v = 1;
                        break;
                     case 14:
                        var2.v = 2;
                     }
                  } else if (var12.indexOf("grouporder:") != -1) {
                     var2.r = true;
                     var12 = var12.substring("grouporder:".length());
                     var2.s = com.aspose.cells.b.a.zo.a(var12);
                  } else if (var12.indexOf("ascending:") != -1) {
                     var2.G = true;
                     var12 = var12.substring("ascending:".length()).trim();
                     var2.F = com.aspose.cells.b.a.zo.a(var12);
                  } else if (var12.indexOf("descending:") != -1) {
                     var2.G = false;
                     var12 = var12.substring("descending:".length()).trim();
                     var2.F = com.aspose.cells.b.a.zo.a(var12);
                  } else if (var12.indexOf("picture:") != -1) {
                     var2.J = true;
                     var12 = var12.substring("picture:".length()).trim().toLowerCase();
                     if ("fittocell".equals(var12)) {
                        var2.K = true;
                     } else if (var12.startsWith("scale")) {
                        try {
                           var2.L = true;
                           var12 = var12.substring("scale".length());
                           int var28 = var12.indexOf(38);
                           if (var28 != -1) {
                              var2.V = com.aspose.cells.b.a.zo.a(var12.substring(0, 0 + var28));
                              var2.U = com.aspose.cells.b.a.zo.a(var12.substring(var28 + 1));
                           } else {
                              var2.V = var2.U = com.aspose.cells.b.a.zo.a(var12);
                           }
                        } catch (Exception var15) {
                           ;
                        }
                     } else {
                        var2.L = false;
                        String[] var13 = com.aspose.cells.b.a.zv.d(var12, '&');

                        for(int var14 = 0; var14 < var13.length; ++var14) {
                           if (var13[var14].startsWith("left:")) {
                              var2.M = true;
                              var2.N = zbni.a(var13[var14].substring("left:".length()).trim(), this.a.getWorksheets().M());
                           } else if (var13[var14].startsWith("top:")) {
                              var2.O = true;
                              var2.P = zbni.a(var13[var14].substring("top:".length()).trim(), this.a.getWorksheets().M());
                           } else if (var13[var14].startsWith("width:")) {
                              var2.Q = true;
                              var2.R = zbni.a(var13[var14].substring("width:".length()).trim(), this.a.getWorksheets().M());
                           } else if (var13[var14].startsWith("height:")) {
                              var2.S = true;
                              var2.T = zbni.a(var13[var14].substring("Height:".length()).trim(), this.a.getWorksheets().M());
                           }
                        }
                     }
                  }
               }
            }
         }
      }

      switch(var5.charAt(0)) {
      case '$':
         var2.m = var2.n = var5.substring(1);
         var2.o = 0;
         ICellsDataTable var21 = this.b(var2.m);
         if (!var4) {
            var1.putValue((String)null);
         }

         if (var21 != null) {
            var2.u = var21.getCount();
            var2.a = 0;
         }
         break;
      case '&':
         var2.m = var5.substring(1, 1 + (var5.length() - 1));
         if (var2.m != null && !"".equals(var2.m)) {
            var2.a = 2;
         }
         break;
      case '=':
         var2.a = 1;
         var2.m = var5;
         break;
      default:
         if (!var4) {
            var1.putValue((String)null);
         }

         var6 = com.aspose.cells.b.a.zv.d(var5, '.');
         String var22 = zbni.b(var6[0]);
         if (var22 == null || "".equals(var22)) {
            return;
         }

         ICellsDataTable var23 = this.b(var22);
         if (var23 == null) {
            return;
         }

         String var25;
         int var27;
         if (var6.length == 2) {
            if (var2.H && var23 != null && var23 instanceof zhv) {
               this.a(var22);
               var23.beforeFirst();
               var23.next();
               Object var24 = var23.get(0);
               ArrayList var26 = new ArrayList();
               com.aspose.cells.b.a.a.ze.a(var26, var24);
               var23 = zbni.a((Collection)var26);
               this.a(var22, var23);
            }

            var25 = zbni.b(var6[1]);
            var27 = -1;
            if (var23 != null) {
               var27 = zbni.a(var23.getColumns(), var25);
            }

            if (var23 != null && var27 != -1) {
               var2.m = var22;
               var2.n = var25;
               var2.o = var27;
               var2.a = 0;
               var2.u = var23.getCount();
               return;
            }
         } else if (var6.length > 2 && var23 != null) {
            var25 = zbni.b(var6[1]);
            var27 = zbni.a(var23.getColumns(), var25);
            if (var27 != -1) {
               var2.m = var22;
               var2.n = var25;
               var2.o = var27;
               var2.W = new String[var6.length - 2];

               for(int var29 = 2; var29 < var6.length; ++var29) {
                  var2.W[var29 - 2] = zbni.b(var6[var29]);
               }

               var2.a = 0;
               var2.u = var23.getCount();
               return;
            }
         }
      }

   }

   private int a(Cells var1, int var2, ArrayList var3, String var4, boolean[] var5) {
      zbnh var6 = null;
      boolean var7 = false;
      var5[0] = false;
      boolean var8 = false;

      int var25;
      for(int var9 = var3.size() - 1; var9 >= 0; --var9) {
         var6 = (zbnh)var3.get(var9);
         if (var6.g) {
            var5[0] = true;
         } else if (var6.j) {
            var8 = true;
         }

         if (var6.w <= 0) {
            Cell var10 = var1.checkCell(var2 + 1, var6.c);
            if (var10 != null) {
               if (var10.getType() == 5) {
                  String var11 = var10.j();
                  if (var11.toLowerCase().startsWith("&=subtotal")) {
                     var11 = var11.substring(2);
                     this.a(var11, var6);
                     var6.A = true;
                     var6.B = var10.s();
                     var7 = true;
                     var10.e();
                     var10.b(15);
                     var6.C = var1.checkRow(var2 + 1);
                  } else if (var11.toLowerCase().startsWith("&=&=")) {
                     var6.D = var11;
                     var6.B = var10.s();
                     var6.E = true;
                     var6.D = var11.substring(3);
                     var10.e();
                     var10.b(15);
                  }
               } else {
                  var6.B = var10.s();
               }
            }
         }

         if (var6.w > 0 && var6.y == null) {
            for(var25 = var9 - 1; var25 >= 0; --var25) {
               zbnh var26 = (zbnh)var3.get(var25);
               if (var26.r) {
                  var6.y = new String[]{var26.n};
                  break;
               }
            }
         }
      }

      if (!var5[0] && !var8) {
         return 0;
      } else {
         HashMap var24 = null;
         var25 = 0;

         for(int var27 = 0; var27 < var3.size(); ++var27) {
            var6 = (zbnh)var3.get(var27);
            if (var6.r) {
               var6.t = -1;
               if (var6.s == -1) {
                  var6.s = var25;
               }

               ++var25;
            }
         }

         zbnh[] var28 = new zbnh[var25];

         for(int var12 = 0; var12 < var3.size(); ++var12) {
            var6 = (zbnh)var3.get(var12);
            if (var6.r) {
               var28[var6.s] = var6;
            }
         }

         HashMap var29 = new HashMap();

         int var13;
         int var14;
         for(var13 = 0; var13 < var3.size(); ++var13) {
            var6 = (zbnh)var3.get(var13);
            if (!var6.r && var6.y != null) {
               for(var14 = 0; var14 < var6.y.length; ++var14) {
                  if (!var29.containsKey(var6.y[var14])) {
                     var29.put(var6.y[var14], false);
                  }
               }
            }
         }

         boolean var30 = false;
         boolean var31 = false;
         ICellsDataTable var15 = this.b(var4);
         int var16 = var15.getCount();
         ArrayList var17 = new ArrayList();
         var15.beforeFirst();

         while(true) {
            while(var15.next()) {
               if (var24 == null) {
                  var24 = this.a(var24, var15, var3, 1);
               } else {
                  var14 = 0;
                  var13 = 0;
                  boolean var18 = true;

                  int var19;
                  for(var19 = 0; var19 < var28.length; ++var19) {
                     var6 = var28[var19];
                     if (var6.a == 0 && var6.r) {
                        Object var20 = var24.get(var6.o);
                        Object var21 = var15.get(var6.o);
                        boolean var22 = zbni.a(var20);
                        boolean var23 = zbni.a(var21);
                        if (var22) {
                           if (var23) {
                              continue;
                           }

                           if (var6.t == -1) {
                              var6.t = var2;
                              var24.put(var6.o, var21);
                              continue;
                           }
                        } else if (!var23 && var20.equals(var21)) {
                           continue;
                        }

                        for(var18 = false; var19 < var28.length; ++var19) {
                           var6 = var28[var19];
                           if (var6.a == 0 && var6.t != -1) {
                              com.aspose.cells.b.a.a.ze.a(var17, (Object)var6);
                              if (var29.containsKey(var6.n)) {
                                 ++var13;
                              }

                              if (var14 < var6.l) {
                                 var14 = var6.l;
                              }
                           }
                        }
                     }
                  }

                  var16 += var13 + var14;
                  if (!var18) {
                     for(var19 = 0; var19 < var17.size(); ++var19) {
                        ((zbnh)var17.get(var19)).t = -1;
                     }

                     var17.clear();
                     var24 = this.a(var24, var15, var3, 1);
                  }
               }
            }

            for(int var32 = 0; var32 < var3.size(); ++var32) {
               var6 = (zbnh)var3.get(var32);
               if (var6.r && var6.t != -1 && var29.containsKey(var6.n)) {
                  ++var16;
               }
            }

            if (var7) {
               --var16;
            }

            return var16 - 1;
         }
      }
   }

   private void b(Cells var1, int var2, ArrayList var3) {
      boolean var4 = false;
      boolean var5 = false;
      zbnh var6 = null;
      int var7 = 0;
      int var8 = 0;
      ArrayList var9 = new ArrayList();

      int var10;
      for(var10 = 0; var10 < var3.size(); ++var10) {
         var6 = (zbnh)var3.get(var10);
         if (var6.r) {
            String var11 = var6.m;
            boolean var12 = false;
            boolean[] var13 = new boolean[]{var12};
            ArrayList var14 = this.a(var3, var11, true, var13, true);
            var12 = var13[0];
            boolean[] var15 = new boolean[]{var4};
            int var16 = this.a(var1, var2, var14, var11, var15);
            var4 = var15[0];
            if (var16 > 0) {
               if (var4) {
                  if (var16 > var7) {
                     var7 = var16;
                  }
               } else {
                  if (var16 > var8) {
                     var8 = var16;
                  }

                  com.aspose.cells.b.a.a.ze.a(var9, (Object)var14);
                  com.aspose.cells.b.a.a.ze.a(var9, (Object)var16);
               }
            }

            var10 = -1;
         }
      }

      for(var10 = 0; var10 < var3.size(); ++var10) {
         var6 = (zbnh)var3.get(var10);
         switch(var6.a) {
         case 0:
            if (var6.g) {
               var4 = true;
            }
            break;
         case 2:
            var5 = true;
         }
      }

      boolean var18 = false;

      int var17;
      for(var17 = 0; var17 < var3.size(); ++var17) {
         var6 = (zbnh)var3.get(var17);
         var10 = var6.c();
         if (var6.g) {
            if (var10 > var7) {
               var7 = var6.c();
            }
         } else if (var6.j) {
            var10 = var6.d();
            if (var10 > var8) {
               var8 = var6.d();
            }
         }
      }

      if (var4) {
         this.a(var1, var2, var7);
      }

      if (var8 - var7 > 0) {
         for(var17 = 0; var17 < var3.size(); ++var17) {
            var6 = (zbnh)var3.get(var17);
            if (var6.j && var6.d() - var7 > 0) {
               CellArea var19 = new CellArea();
               var19.StartRow = var6.b + 1;
               var19.StartColumn = var6.c;
               var19.EndRow = var6.b + 1;
               var19.EndColumn = var6.c;
               this.a((Cells)var1, (CellArea)var19, var6.d() - var7, 0);
            }
         }

         if (var9.size() > 0) {
            for(var17 = 0; var17 < var9.size(); var17 += 2) {
               ArrayList var20 = (ArrayList)var9.get(var17);
               int var21 = (Integer)var9.get(var17 + 1);
               if (var21 > var7) {
                  CellArea var22 = new CellArea();

                  while(var20.size() > 0) {
                     var6 = (zbnh)var20.get(0);
                     var22.StartRow = var6.b + 1;
                     var22.StartColumn = var6.c;
                     var22.EndRow = var6.b + 1;
                     var22.EndColumn = var6.c;

                     while(var20.size() > 0) {
                        var20.remove(0);
                        if (var20.size() > 0) {
                           var6 = (zbnh)var20.get(0);
                           if (var6.c != var22.EndColumn + 1) {
                              break;
                           }

                           ++var22.EndColumn;
                        }
                     }
                  }

                  this.a((Cells)var1, (CellArea)var22, var21 - var7, 0);
               }
            }
         }
      }

      if (var5) {
         for(var17 = 0; var17 < var3.size(); ++var17) {
            var6 = (zbnh)var3.get(var17);
            if (var6.a == 2) {
               var6.p = (var7 > var8 ? var7 : var8) + 1;
            }
         }
      }

   }

   public boolean getUpdateReference() {
      return this.f;
   }

   public void setUpdateReference(boolean value) {
      this.f = value;
   }

   public boolean getCalculateFormula() {
      return this.g;
   }

   public void setCalculateFormula(boolean value) {
      this.g = value;
   }

   public void process() throws Exception {
      this.process(false);
   }

   public void process(boolean isPreserved) throws Exception {
      ArrayList var2 = new ArrayList();

      int var3;
      zbnm var4;
      for(var3 = 0; var3 < this.a.getWorksheets().getCount(); ++var3) {
         var4 = this.a(var3, isPreserved);
         if (var4 != null && var4.getCount() > 0) {
            com.aspose.cells.b.a.a.ze.a(var2, (Object)var4);
         }
      }

      for(var3 = 0; var3 < var2.size(); ++var3) {
         var4 = (zbnm)var2.get(var3);
         if (var4 != null && var4.getCount() != 0) {
            this.a(var4);
         }
      }

      boolean var9 = false;
      if (this.g) {
         var9 = true;
         this.a.getSettings().setCreateCalcChain(false);
         this.a.calculateFormula();
      }

      for(int var10 = 0; var10 < this.a.getWorksheets().getCount(); ++var10) {
         PivotTableCollection var5 = this.a.getWorksheets().get(var10).getPivotTables();
         if (var5.getCount() != 0) {
            for(int var6 = 0; var6 < var5.getCount(); ++var6) {
               if (this.a(var2, var5.get(var6))) {
                  if (!var5.get(var6).getRefreshDataOnOpeningFile()) {
                     var5.get(var6).setRefreshDataOnOpeningFile(true);
                  }

                  if (!var9) {
                     var9 = true;
                     this.a.getSettings().setCreateCalcChain(false);
                     this.a.calculateFormula();
                  }

                  var5.get(var6).setRefreshDataFlag(true);

                  try {
                     var5.get(var6).refreshData();
                  } catch (Exception var8) {
                     ;
                  }
               }
            }
         }
      }

   }

   private boolean a(ArrayList var1, PivotTable var2) {
      if (var2.d != null && var2.d.e != null && var2.d.e.length > 0) {
         int var3 = var1.size();
         int var4 = var2.d.e.length;
         zqr var5 = null;
         zbnm var6 = null;

         for(int var7 = 0; var7 < var3; ++var7) {
            var6 = (zbnm)var1.get(var7);
            if (var6 != null && var6.getCount() != 0) {
               for(int var8 = 0; var8 < var4; ++var8) {
                  var5 = var2.d.e[var8];
                  if (var5.a != null && var5.a.getName().equals(var6.a().getName())) {
                     return true;
                  }
               }
            }
         }

         return false;
      } else {
         return false;
      }
   }

   public void process(int sheetIndex, boolean isPreserved) throws Exception {
      zbnm var3 = this.a(sheetIndex, isPreserved);
      if (var3 != null) {
         this.a(var3);
      }
   }

   private boolean a(Cell var1, ArrayList var2) {
      for(int var3 = 0; var3 < var2.size(); ++var3) {
         CellArea var4 = (CellArea)var2.get(var3);
         if (var1.getRow() >= var4.StartRow && var1.getRow() <= var4.EndRow && var1.getColumn() >= var4.StartColumn && var1.getColumn() <= var4.EndColumn) {
            return true;
         }
      }

      return false;
   }

   private zbnm a(int var1, boolean var2) {
      Worksheet var3 = this.a.getWorksheets().get(var1);
      zbnm var4 = new zbnm(var3);
      this.h = var4;
      zbnh var5 = null;
      ArrayList var6 = new ArrayList();
      Cells var7 = var3.getCells();
      var7.w();
      ArrayList var8 = var7.x();

      int var12;
      for(int var9 = var7.getRows().getCount() - 1; var9 >= 0; --var9) {
         Row var10 = var7.getRows().getRowByIndex(var9);
         boolean var11 = false;

         Cell var13;
         String var14;
         for(var12 = var10.a() - 1; var12 >= 0; --var12) {
            var13 = var10.getCellByIndex(var12);
            if (var13.c.c == 4 && (var8 == null || !this.a(var13, var8))) {
               var14 = var13.j();
               if (var14.toLowerCase().startsWith("&=subtotal")) {
                  var11 = true;
                  break;
               }
            }
         }

         for(var12 = var10.a() - 1; var12 >= 0; --var12) {
            var13 = var10.getCellByIndex(var12);
            if (var13.c.c == 4 && (var8 == null || !this.a(var13, var8))) {
               var14 = var13.j();
               if (var14.startsWith("&=") && !var14.toLowerCase().startsWith("&=subtotal") && (!var11 || !var14.startsWith("&=&="))) {
                  var5 = new zbnh(var13.getRow(), var13.getColumn());
                  this.a(var13, var5, var6, var2);
                  if (var5.a != 3) {
                     var4.a(0, var5);
                     if (var5.f) {
                        var6.add(0, var5);
                     }
                  }
               }
            }
         }

         if (var6.size() > 0) {
            this.b(var7, var10.getIndex(), var6);
            var6.clear();
         }
      }

      if (var4.getCount() == 0) {
         return null;
      } else {
         if (this.i != null && var7.q().getCount() > 0) {
            ArrayList var18 = new ArrayList(var7.q().getCount());

            int var19;
            for(var19 = 0; var19 < var7.q().getCount(); ++var19) {
               com.aspose.cells.b.a.a.ze.a(var18, (Object)var7.q().a(var19));
            }

            for(var19 = 0; var19 < this.i.size(); ++var19) {
               zanh var20 = (zanh)this.i.get(var19);

               for(var12 = 0; var12 < var18.size(); ++var12) {
                  CellArea var21 = (CellArea)var18.get(var12);
                  if (var21.StartRow == var20.b && var21.EndRow == var20.b) {
                     int var22 = var20.a;
                     int var15 = var21.StartColumn;
                     int var16 = var21.EndColumn - var15 + 1;

                     for(int var17 = 1; var17 <= var22; ++var17) {
                        var7.merge(var20.b + var17, var15, 1, var16);
                     }
                  }
               }
            }

            this.i.clear();
         }

         this.a(var7, var4);
         return var4;
      }
   }

   private ArrayList a(zbnm var1, int var2, boolean var3) {
      ArrayList var4 = new ArrayList();

      for(int var5 = 0; var5 < var1.getCount(); ++var5) {
         if (var1.a(var5).c == var2 && !var1.a(var5).f) {
            com.aspose.cells.b.a.a.ze.a(var4, (Object)var1.a(var5));
            if (var3) {
               var1.removeAt(var5--);
            }
         }
      }

      return var4;
   }

   private void a(Cells var1, zbnm var2) {
      boolean var3 = false;
      boolean var4 = false;
      boolean var5 = false;
      ArrayList var6 = null;
      int var7 = var1.b((short)0);

      for(int var8 = var7; var8 >= 0; --var8) {
         var6 = this.a(var2, var8, false);
         if (var6.size() != 0) {
            int var13 = 0;
            int var14 = 0;
            int var15 = 0;
            zbnh var9 = null;

            int var10;
            int var16;
            for(var10 = 0; var10 < var6.size(); ++var10) {
               var9 = (zbnh)var6.get(var10);
               if (var9.b() > var15) {
                  var15 = var9.b();
               }

               boolean var11 = false;
               if (var9.g) {
                  var16 = var9.c();
                  if (var16 > var13) {
                     var13 = var9.c();
                  }
               } else if (var9.j) {
                  var16 = var9.d();
                  if (var16 > var14) {
                     var14 = var9.d();
                  }
               }
            }

            if (var13 != 0) {
               this.a(var1, var9, var13);
            }

            if (var14 > var13) {
               for(var10 = 0; var10 < var6.size(); ++var10) {
                  var9 = (zbnh)var6.get(var10);
                  if (var9.j) {
                     var16 = var9.d();
                     if (var16 > var13) {
                        CellArea var12 = new CellArea();
                        var12.StartRow = var9.b;
                        var12.StartColumn = var9.c + 1;
                        var12.EndRow = var9.b;
                        var12.EndColumn = var9.c + 1;
                        this.a((Cells)var1, (CellArea)var12, var14 - var13, 3);
                     }
                  }
               }
            }

            for(var10 = 0; var10 < var6.size(); ++var10) {
               var9 = (zbnh)var6.get(var10);
               if (var9.a == 2 && !var9.f) {
                  var9.p = var15;
               }
            }
         }
      }

   }

   private void a(zbnh var1, Cells var2, int var3, int var4, Object var5) throws Exception {
      if (var1.J) {
         if (var5 != null && var5 instanceof byte[]) {
            this.a(var2, var1, var3, var4, (byte[])((byte[])var5));
         }
      } else if (var1.I) {
         var2.a(var3, var4, false).setHtmlString(com.aspose.cells.b.a.zr.a(var5));
      } else {
         Cell var6 = var2.a(var3, var4, false);
         if (var5 != null && var1.W != null) {
            var5 = com.aspose.cells.a.c.zu.a(var1.W, var5);
         }

         if (var1.q && var5 != null && var5 instanceof String) {
            var6.putValue((String)var5, true);
         } else {
            var6.putValue(var5);
         }

         if (var1.h) {
            var6.b(var1.i);
         }
      }

   }

   private void a(zbnh var1, Cells var2, int var3, int var4) {
      String var5 = var1.m;
      Cell var6 = var2.a(var1.d, var1.e, false);
      var6.setFormula(zbni.a(var5, var1.d, var1.e));
      if (var1.h) {
         var6.b(var1.i);
      }

   }

   private void b(Cells var1, zbnm var2) throws Exception {
      ArrayList var3 = null;
      Object var4 = null;
      int var5 = var1.b((short)0);

      for(int var6 = var5; var6 >= 0; --var6) {
         var3 = this.a(var2, var6, true);
         if (var3.size() != 0) {
            for(int var7 = 0; var7 < var3.size(); ++var7) {
               zbnh var8 = (zbnh)var3.get(var7);
               var8.a();
               if (var8.a == 1) {
                  String var9 = zbni.a(var8.m, var8.b, var8.c);
                  var1.a(var8.b, var8.c, false).setFormula(var9);
                  var3.remove(var7--);
               }
            }

            while(var3.size() > 0) {
               zbnh var13 = null;

               for(int var14 = 0; var14 < var3.size(); ++var14) {
                  var13 = (zbnh)var3.get(var14);
                  if (var13.a == 0) {
                     break;
                  }

                  var13 = null;
               }

               if (var13 == null) {
                  break;
               }

               boolean var15 = false;
               boolean[] var16 = new boolean[]{var15};
               ArrayList var10 = this.a(var3, var13.m, true, var16, false);
               var15 = var16[0];
               ICellsDataTable var11 = this.b(var13.m);
               var11.beforeFirst();

               while(var11.next()) {
                  for(int var12 = 0; var12 < var10.size(); ++var12) {
                     var13 = (zbnh)var10.get(var12);
                     switch(var13.a) {
                     case 0:
                        var4 = var11.get(var13.o);
                        this.a(var13, var1, var13.d, var13.e, var4);
                        var13.e += var13.l + 1;
                        break;
                     case 2:
                        this.a(var13, var1, var13.d, var13.e);
                        var13.e += 1 + var13.l;
                     }
                  }
               }
            }
         }
      }

   }

   private void a(Cells var1, zbnh var2, int var3) {
      int var4 = var2.b;
      int var5 = var2.c;
      int var6 = var5 + 1;

      int var7;
      for(var7 = 0; var7 < var1.q().getCount(); ++var7) {
         CellArea var8 = var1.q().a(var7);
         if (var8.StartRow <= var4 && var8.EndRow >= var4 && var8.StartColumn <= var5 && var8.EndColumn >= var5) {
            var6 = var8.EndColumn + 1;
            break;
         }
      }

      for(var7 = 0; var7 < this.h.getCount(); ++var7) {
         zbnh var9 = this.h.a(var7);
         if (var9.c > var5) {
            var9.c += var3;
         }
      }

      if (var2.h) {
         var1.getRows().e(var6, var3);
         if (var6 <= var1.getMaxColumn()) {
            var1.a((short)(var1.getMaxColumn() + var3));
         }

         var1.getColumns().c(var6, var3);
      } else {
         var1.insertColumns(var6, var3);
      }

      this.a(var1, -1, var6 - 1, false, var3, true, -1);
   }

   private void a(Cells var1, int var2, int var3, boolean var4, int var5, boolean var6, int var7) {
      int var8;
      for(var8 = 0; var8 < var1.getRows().getCount(); ++var8) {
         Row var9 = var1.getRows().getRowByIndex(var8);

         for(int var10 = 0; var10 < var9.a(); ++var10) {
            Cell var11 = var9.getCellByIndex(var10);
            if (var11.v() != null) {
               var11.a(zyo.a(var1.h(), true, var2, var3, var4, var5, var6, var7, -1, -1, var11.v()));
            }
         }
      }

      for(var8 = 0; var8 < var1.r().getCount(); ++var8) {
         Worksheet var16 = var1.r().get(var8);
         ChartCollection var18 = var16.getCharts();

         for(int var20 = 0; var20 < var18.getCount(); ++var20) {
            Chart var12 = var18.get(var20);

            for(int var13 = 0; var13 < var12.getNSeries().getCount(); ++var13) {
               Series var14 = var12.getNSeries().get(var13);
               if (var14.m() != null && var14.m().f() != null) {
                  var14.m().a(zyo.a(var1.h(), var16 == var1.h(), 0, 0, var4, var5, var6, var7, -1, -1, var14.m().f()));
               }

               if (var14.l() != null && var14.l().f() != null) {
                  var14.l().a(zyo.a(var1.h(), var16 == var1.h(), 0, 0, var4, var5, var6, var7, -1, -1, var14.l().f()));
               }
            }
         }
      }

      NameCollection var15 = var1.r().getNames();

      for(int var17 = 0; var17 < var15.getCount(); ++var17) {
         Name var19 = var15.get(var17);
         if (var19.b() != null) {
            var19.a(zyo.a(var1.h(), false, var2, var3, var4, var5, var6, var7, -1, -1, var19.b()));
            var19.h((String)null);
         }
      }

   }

   private void a(Cells var1, CellArea var2, int var3, int var4) {
      for(int var5 = 0; var5 < this.h.getCount(); ++var5) {
         zbnh var6 = this.h.a(var5);
         switch(var4) {
         case 0:
            if (var2.StartColumn <= var6.c && var2.EndColumn >= var6.c && var6.b > var2.StartRow) {
               var6.b += var3;
            }
            break;
         case 3:
            if (var2.StartRow <= var6.b && var2.EndRow >= var6.b && var6.c > var2.StartColumn) {
               var6.c += var3;
            }
         }
      }

      var1.insertRange(var2, var3, var4, false);
      if (var3 <= 0 && var4 == 0) {
         this.a(var1, var2.StartRow - 1, var2.StartColumn, true, var3, false, var2.EndColumn);
      }

   }

   private void a(Cells var1, int var2, int var3) {
      if (var3 != 0) {
         int var4;
         for(var4 = 0; var4 < this.h.getCount(); ++var4) {
            zbnh var5 = this.h.a(var4);
            if (var5.b > var2) {
               var5.b += var3;
            }
         }

         var1.insertRows(var2 + 1, var3, this.f);
         this.a(var1, var2, -1, true, var3, true, -1);
         if (var1.q().getCount() != 0) {
            if (this.i == null) {
               this.i = new ArrayList();
            } else {
               for(var4 = 0; var4 < this.i.size(); ++var4) {
                  zanh var8 = (zanh)this.i.get(var4);
                  if (var8.b > var2) {
                     var8.b += var3;
                  }
               }
            }

            com.aspose.cells.b.a.a.ze.a(this.i, (Object)(new zanh(var3, var2)));
         }

         if (var1.h().getListObjects().getCount() != 0) {
            ListObjectCollection var7 = var1.h().getListObjects();

            for(int var9 = 0; var9 < var7.getCount(); ++var9) {
               ListObject var6 = var7.get(var9);
               if (var6.getEndRow() == var2) {
                  var6.c(var6.getEndRow() + var3);
               }
            }
         }

         if (var1.r().U().getCount() != 0) {
            for(var4 = 0; var4 < var1.r().U().getCount(); ++var4) {
               var1.r().U().a(var4).a(var2, var3, var1.h());
            }
         }

      }
   }

   public String[] getSmartMarkers() {
      return this.a.getWorksheets().g.f();
   }

   public void setDataSource(String dataSource, ICellsDataTable cellsDataTable) {
      this.a(dataSource, cellsDataTable);
   }

   public void setDataSource(String dataSource, ResultSet rs, int rowCount) {
      try {
         if (dataSource == null) {
            ResultSetMetaData var4 = rs.getMetaData();
            dataSource = var4.getTableName(1);
         }
      } catch (Exception var5) {
         throw new CellsException(6, "Invalid data source of smart marker");
      }

      this.a((String)dataSource, (ICellsDataTable)(new zhp(rs, rowCount)));
   }

   public void setDataSource(String dataSource, ResultSet rs) {
      this.setDataSource(dataSource, rs, -1);
   }

   public void setDataSource(ResultSet rs) {
      this.setDataSource((String)null, rs, -1);
   }

   private ArrayList a(ArrayList var1, String var2, boolean var3, boolean[] var4, boolean var5) {
      ArrayList var6 = new ArrayList();
      var4[0] = false;

      for(int var7 = 0; var7 < var1.size(); ++var7) {
         zbnh var8 = (zbnh)var1.get(var7);
         switch(var8.a) {
         case 2:
            if (!var3) {
               break;
            }

            boolean var9 = false;
            zbnh var11;
            if (var6.size() == 0) {
               for(int var10 = var7 + 1; var10 < var1.size(); ++var10) {
                  var11 = (zbnh)var1.get(var10);
                  if (var11.a == 0) {
                     if (com.aspose.cells.b.a.zv.b(var11.m, var2)) {
                        var9 = true;
                     }
                     break;
                  }
               }
            } else {
               zbnh var18 = var7 == 0 ? null : (zbnh)var1.get(var7 - 1);
               var11 = (zbnh)var6.get(var6.size() - 1);
               if (var11.a(var5) + 1 == var8.a(var5)) {
                  var9 = true;
               } else {
                  int var12 = var8.a(var5) - var11.a(var5);
                  int var13 = Integer.MAX_VALUE;
                  if (var18 != null) {
                     var13 = var8.a(var5) - var18.a(var5);
                  }

                  if (var13 > var12) {
                     if (var7 + 1 == var1.size()) {
                        var9 = true;
                     } else {
                        boolean var14 = true;

                        for(int var15 = var7 + 1; var15 < var1.size(); ++var15) {
                           zbnh var16 = (zbnh)var1.get(var15);
                           if (var16.a == 0) {
                              var14 = false;
                              if (com.aspose.cells.b.a.zv.b(var16.m, var2)) {
                                 var9 = true;
                              } else {
                                 int var17 = var16.a(var5) - var8.a(var5);
                                 if (var17 != var15 - var7 && var12 <= var17) {
                                    var9 = true;
                                 }
                              }
                              break;
                           }
                        }

                        if (var14) {
                           var9 = true;
                        }
                     }
                  }
               }
            }

            if (var9) {
               com.aspose.cells.b.a.a.ze.a(var6, (Object)var8);
               var1.remove(var7--);
            }
            break;
         default:
            if (com.aspose.cells.b.a.zv.a(var2, var8.m, true) == 0) {
               com.aspose.cells.b.a.a.ze.a(var6, (Object)var8);
               var1.remove(var7--);
            }

            if (var8.r) {
               var4[0] = true;
            }
         }
      }

      return var6;
   }

   private void a(String var1) {
      this.b.remove(var1.toUpperCase());
   }

   private void a(String var1, ICellsDataTable var2) {
      this.b.put(var1.toUpperCase(), var2);
   }

   private ICellsDataTable b(String var1) {
      return (ICellsDataTable)this.b.get(var1.toUpperCase());
   }

   private HashMap a(HashMap var1, ICellsDataTable var2, ArrayList var3, int var4) {
      int var5;
      zbnh var6;
      Object var7;
      if (var1 == null) {
         var1 = new HashMap();

         for(var5 = 0; var5 < var3.size(); ++var5) {
            var6 = (zbnh)var3.get(var5);
            if (var6.r) {
               var7 = var2.get(var6.o);
               var1.put(var6.o, var7);
               if (var6.t == -1 && !zbni.a(var7)) {
                  var6.t = var4;
               }
            }
         }
      } else {
         for(var5 = 0; var5 < var3.size(); ++var5) {
            var6 = (zbnh)var3.get(var5);
            if (var6.r) {
               var7 = var2.get(var6.o);
               var1.put(var6.o, var7);
               if (var6.t == -1 && !zbni.a(var7)) {
                  var6.t = var4;
               }
            }
         }
      }

      return var1;
   }
}
